import request from '@/utils/request'

// 用户列表
export function user_list(data) {
  return request({
    url: '/system/user/list',
    method: 'get',
    params: data
  })
}

// 角色列表
export function role_list(data) {
  return request({
    url: '/system/role/list',
    method: 'get',
    params: data
  })
}

// 组织列表
export function dept_list(data) {
  return request({
    url: '/system/dept/list',
    method: 'get',
    params: data
  })
}

// 组织下拉框（新增用户）
export function dept_select(data) {
  return request({
    url: '/system/dept/treeselect',
    method: 'get',
    params: data
  })
}

// 角色下拉框（新增用户）
export function role_select(data) {
  return request({
    url: '/system/role/optionselect',
    method: 'get',
    data: data
  })
}

// 权限下拉框（新增用户）
export function auth_select(data) {
  return request({
    url: '/system/permission/optionSelect',
    method: 'get',
    data: data
  })
}

// 登录辅助下拉框（新增用户）
export function loginpolicy_select(data) {
  return request({
    url: '/system/user/secondaryLoginPolicyList',
    method: 'get',
    data: data
  })
}

// 用户有效期
export function user_duration(data) {
  return request({
    url: '/system/user/getUserDuration',
    method: 'get',
    params: data
  })
}

// 用户添加
export function user_add(data) {
  return request({
    url: '/system/user/add',
    method: 'post',
    data: data
  })
}

// 用户详情
export function user_info(data) {
  return request({
    url: '/system/user/getInfoByUserId',
    method: 'post',
    data: data
  })
}

// 用户更新
export function user_edit(data) {
  return request({
    url: '/system/user/edit',
    method: 'post',
    data: data
  })
}

// 用户批量更新状态
export function user_status(data) {
  return request({
    url: '/system/user/updateStatus',
    method: 'post',
    data: data
  })
}

// 用户批量更新状态
export function user_pwd(data) {
  return request({
    url: '/system/user/resetPwd',
    method: 'post',
    data: data
  })
}

// 组织添加
export function dept_add(data) {
  return request({
    url: '/system/dept/add',
    method: 'post',
    data: data
  })
}

// 组织详情
export function dept_info(data) {
  return request({
    url: '/system/dept/getInfo',
    method: 'get',
    params: data
  })
}

// 组织更新
export function dept_edit(data) {
  return request({
    url: '/system/dept/edit',
    method: 'post',
    data: data
  })
}

// 组织删除
export function dept_delete(data) {
  return request({
    url: '/system/dept/remove',
    method: 'get',
    params: data
  })
}

// 角色添加
export function role_add(data) {
  return request({
    url: '/system/role/add',
    method: 'post',
    data: data
  })
}

// 角色更新
export function role_edit(data) {
  return request({
    url: '/system/role/edit',
    method: 'post',
    data: data
  })
}

// 角色详情
export function roleInfo(data) {
  return request({
    url: '/system/role/getInfo',
    method: 'get',
    params: data
  })
}

// 查询菜单下拉树结构
export function menuTreeselect() {
  return request({
    url: '/system/menu/treeselect',
    method: 'get'
  })
}

// 查询菜单下拉树结构
export function getMenuTreeForRole(data) {
  return request({
    url: '/system/menu/getMenuTreeForRole',
    method: 'get',
    params: data
  })
}

// 查询组织下拉树结构
export function deptTreeselect(data) {
  return request({
    url: '/system/dept/roleDeptTreeselect',
    method: 'get',
    params: data
  })
}

// 查询数据下拉树结构
export function dataSourceTreeselect() {
  return request({
    url: '/system/role/selectDataList',
    method: 'get'
  })
}

// 根据角色ID查询菜单下拉树结构
export function roleMenuTreeselect(roleId) {
  return request({
    url: '/system/menu/roleMenuTreeselect/' + roleId,
    method: 'get'
  })
}

// 角色删除
export function role_delete(data) {
  return request({
    url: '/system/role/delete',
    method: 'post',
    data: data
  })
}

// 角色状态编辑
export function role_status(data) {
  return request({
    url: '/system/role/changeStatus',
    method: 'post',
    data: data
  })
}

// 停用启用
export function updateDeptStatus(data) {
  return request({
    url: '/system/dept/updateDeptStatus',
    method: 'post',
    data: data
  })
}

// 修改二次登陆辅助策略
export function batchUpdateSecondPolicy(data) {
  return request({
    url: '/system/user/batchUpdateSecondPolicy',
    method: 'post',
    data: data
  })
}

/**
 * 新权限管理接口
 */
// 获取角色树
export function getRoleTree(params) {
  return request({
    url: '/system/permission/getRoleTree',
    method: 'get',
    params
  })
}

// 新增时获取角色树
export function getRoleTreeForAdd(params) {
  return request({
    url: '/system/permission/getRoleTreeForAdd',
    method: 'get',
    params
  })
}

// 编辑时获取角色树
export function getRoleTreeForEdit(params) {
  return request({
    url: '/system/permission/getRoleTreeForEdit',
    method: 'get',
    params
  })
}

// 获取部门树
export function getDeptTree(params) {
  return request({
    url: '/system/permission/getDeptTreeForPermission',
    method: 'get',
    params
  })
}

// 新增时获取部门树
export function getDeptTreeForPermissionForAdd(params) {
  return request({
    url: '/system/permission/getDeptTreeForPermissionForAdd',
    method: 'get',
    params
  })
}

// 编辑时获取部门树
export function getDeptTreeForPermissionForEdit(params) {
  return request({
    url: '/system/permission/getDeptTreeForPermissionForEdit',
    method: 'get',
    params
  })
}

// 获取权限列表
export function getAuthList(params) {
  return request({
    url: '/system/permission/list',
    method: 'get',
    params
  })
}

// 新增
export function authAdd(data) {
  return request({
    url: '/system/permission/add',
    method: 'post',
    data: data,
  })
}

// 根据id获取数据
export function getAuthInfo(params) {
  return request({
    url: '/system/permission/getInfo',
    method: 'get',
    params,
  })
}

// 编辑
export function authEdit(data) {
  return request({
    url: '/system/permission/edit',
    method: 'post',
    data: data,
  })
}

// 停用/启用
export function changeStatus(data) {
  return request({
    url: '/system/permission/changeStatus',
    method: 'post',
    data: data,
  })
}

// 删除
export function authDelete(data) {
  return request({
    url: '/system/permission/delete',
    method: 'post',
    data: data,
  })
}

// 权限绑定人员
export function batchAddUserPermission(data) {
  return request({
    url: '/system/permission/batchAddUserPermission',
    method: 'post',
    data: data,
  })
}

// 权限解绑
export function batchDeleteUserPermission(data) {
  return request({
    url: '/system/permission/batchDeleteUserPermission',
    method: 'post',
    data: data,
  })
}

//角色绑定
export function batchAddUserRole(data) {
  return request({
    url: '/system/role/batchAddUserRole',
    method: 'post',
    data: data,
  })
}

//角色解绑
export function batchDeleteUserRole(data) {
  return request({
    url: '/system/role/batchDeleteUserRole',
    method: 'post',
    data: data,
  })
}

// 设置人员获取人员列表
export function getUserList(data) {
  return request({
    url: '/system/user/queryUnLogOffUSerlist',
    method: 'get',
    params: data,
  })
}


// 删除前校验(数据权限）
export function checkBeforeDeleteForPerm(data) {
  return request({
    url: '/system/permission/checkBeforeDelete',
    method: 'post',
    data: data,
  })
}

// 删除角色前校验
export function deleteForCheckForRole(data) {
  return request({
    url: '/system/role/checkBeforeDelete',
    method: 'post',
    data: data
  })
}

// 删除组织前校验
export function deleteForCheckForDept(data) {
  return request({
    url: '/system/dept/checkBeforeDelete',
    method: 'get',
    params: data
  })
}

//同步用户、更新用户
export function synchronizeUser(params) {
  return request({
    url: '/system/user/syncUser',
    method: 'get',
    params
  })
}

//同步组织、更新组织
export function synchronizeOrg(params) {
  return request({
    url: '/system/dept/syncOrg',
    method: 'get',
    params
  })
}
